package com.zy.qudadid.ui.fragment;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.Shop;
import com.zy.qudadid.presenter.ShopPresenter;
import com.zy.qudadid.ui.activity.base.BaseFragment;
import com.zy.qudadid.ui.activity.base.RecycleViewFragment;
import com.zy.qudadid.ui.activity.base.SwipeRecycleViewFragment;
import com.zy.qudadid.ui.adapter.ShopAdapter;
import com.zy.qudadid.ui.view.ShopView;
import com.zy.qudadid.ui.widget.SpacesItemDecoration;

import java.util.ArrayList;

/**
 * Created by liuchao on 2017/4/10.
 */

public class ShopFragment extends RecycleViewFragment<ShopPresenter,ShopAdapter,Shop> implements ShopView {


    @Override
    protected ShopAdapter provideAdapter() {
        return new ShopAdapter(getContext());
    }

    @Override
    protected RecyclerView.LayoutManager provideLayoutManager() {
        return new GridLayoutManager(getContext(),2);
    }

    @Override
    public void initListeners() {

    }

    @Override
    protected String provideTitle() {
        return "";
    }

    @Override
    protected void initThings(View view) {
        super.initThings(view);

        int spacingInPixels = 10;
        recyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));



//        list.add(new Shop());
//        list.add(new Shop());
//        list.add(new Shop());
//        list.add(new Shop());
//        list.add(new Shop());
//        list.add(new Shop());
//        bd(list);
    }

    @Override
    public void onResume() {
        super.onResume();
        presenter.getData(1,1);
    }

    @Override
    public int provideLayoutId() {
        return R.layout.fragment_shop;
    }

    @Override
    public ShopPresenter createPresenter() {
        return new ShopPresenter();
    }

    @Override
    public void onItemClick(View view, int pos, Shop item) {

    }

    @Override
    public void success(ArrayList<Shop> data) {
        bd(data);
    }

    @Override
    public void error(String str) {
        toast(str);
    }
}
